import request from '@/util/http/index'

/**
 * // 根据用户权限查询变电站列表,, 指定parentId可查询指定主站的子站，此时stationType必需传1
 * @param stationType stationType = 0主站/1子站/-1全部
 * @param parentId
 * @returns
 */
export const getStationListByUser = async (stationType = -1, parentId = 0) => {
  return await request.get({
    url: '/crc/station/getListByLoginUser',
    params: { stationType, parentId }
  })
}

/**
 * 根据场站，获取下面的设备列表
 * @param stationId
 * @param parentId
 * @param productCategoryCode
 * @returns
 */
export const stationAndDeviceList = async (
  stationId: number,
  parentId?: number,
  productCategoryCode?: string
) => {
  const params = {
    stationId: stationId,
    parentId: parentId,
    productCategoryCode: productCategoryCode
  }
  return await request.get({ url: `/crc/device/stationAndDeviceList`, params })
}

// 查询物模型服务列表
export const getTslServiceList = async (productId: number) => {
  return await request.get({ url: `/crc/tsl-service/tslServiceList`, params: { productId } })
}

/**
 * 查询物模型属性列表
 * @param productId
 * @param tslServiceId
 * @param haveChild
 * @returns
 */
export const getTslPropertyList = async (
  productId: number,
  tslServiceId?: number,
  haveChild?: number
) => {
  const params = {
    productId: productId,
    tslServiceId: tslServiceId,
    haveChild: haveChild
  }
  return await request.get({ url: `/crc/tsl-property/tslPropertyList`, params })
}
